package com.mayflygeek.mayflyask.framework.orm;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Session;
import org.springframework.data.domain.Page;

/**
 * @author 虫虫
 * @team 蜉蝣极客
 * @link www.mayflygeek.com
 * @Emial chongchong@mayflygeek.com
 * 
 */
public interface Hibernatify {
	Session getSession();
	
	<T, ID extends Serializable> T get(Class<T> type, ID id);
	
	@SuppressWarnings("unchecked")
	<T, ID extends Serializable> List<T> get(Class<T> type, ID id, ID... rest);
	
	<T, ID extends Serializable> List<T> get(Class<T> type, Iterable<ID> ids);
	
	<T, ID extends Serializable> T find(Class<T> type, ID id);
	
	<T> List<T> find(Class<T> type);
	
	@SuppressWarnings("unchecked")
	<T, ID extends Serializable> List<T> find(Class<T> type, ID id, ID... rest);
	
	<T, ID extends Serializable> List<T> find(Class<T> type, Iterable<ID> ids);
	
	<T> T put(T entity);
	
	@SuppressWarnings("unchecked")
	<T> List<T> put(T entity, T... rest);
	
	<T> List<T> put(List<? extends T> entities);
	
	<T> T delete(T entity);
	
	@SuppressWarnings("unchecked")
	<T> List<T> delete(T entity, T... rest);
	
	<T> List<T> delete(List<T> entities);
	
	<ID extends Serializable> void deleteById(Class<?> type, ID id);
	
	@SuppressWarnings("unchecked")
	<ID extends Serializable> void deleteById(Class<?> type, ID id, ID... rest);
	
	<ID extends Serializable> void deleteById(Class<?> type, Iterable<ID> ids);
	
	<T, RT> List<RT> list(Query<T, RT> query);
	
	<T, RT> RT unique(Query<T, RT> query);
	
	<T, RT> Page<RT> page(Query<T, RT> query);
	
	<T> int count(Class<T> type);
	
	<T, RT> int count(Query<T, RT> query);
}
